/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2024-03-18
 * Time: 22:23
 */
public class Logln {
    private String userName = "admin";
    private String password = "123456";
    public void loginInfo(String userName, String password)
    throws UserNameException,PassWordException{
        if (!this.userName.equals(userName)) {
            throw new UserNameException("用户名异常！");
        }
        if (!this.password.equals(password)) {
            throw new PassWordException("密码异常！");
        }
        System.out.println("登陆成功");
    }
    public static void main(String[] args) {
        Logln logln = new Logln();
        try {
            logln.loginInfo("admin", "123456");
        }
        catch (UserNameException userNameException) {
            System.out.println("捕获了UserNameException");
            userNameException.printStackTrace();
        }
        catch (PassWordException passWordException) {
            System.out.println("捕获了PassWordException");
            passWordException.printStackTrace();
        }finally {
            System.out.println("finally...");
        }
    }
}
